package com.example.lago_di_sangue;

import android.content.Context;
import android.graphics.Canvas;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class GamePanel extends SurfaceView implements
SurfaceHolder.Callback {

	private static final String TAG = GamePanel.class.getSimpleName();
	
	private GameThread thread;
	
	public GamePanel(Context context) {
		super(context);

		getHolder().addCallback(this);

		thread = new GameThread(getHolder(), this);
		
		setFocusable(true);
	}

	public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
		
	}

	public void surfaceCreated(SurfaceHolder arg0) {
		thread.setRunning(true);
		thread.start();		
	}

	public void surfaceDestroyed(SurfaceHolder holder) {
		Log.d(TAG, "Surface is being destroyed");

		boolean retry = true;
		while (retry) {
			try {
				thread.join();
				retry = false;
			} catch (InterruptedException e) {

			}
		}
		Log.d(TAG, "Thread was shut down cleanly");		
	}
	
	public boolean onTouchEvent(MotionEvent event) {

		return true;
	}

	public void render(Canvas canvas) {

	}

	public void update() {

	}

}
